#include <iostream>
#include <vector>
#include <string>
using namespace std;
int l[100005], r[100005], a[100005], idx = 1;

void erase(int k)
{
    r[l[k]] = r[k];
    l[r[k]] = l[k];
}

void insert_l(int k, int x)
{
    a[++idx] = x;
    l[idx] = l[k]; r[l[k]] = idx;
    r[idx] = k; l[k] = idx;
}

void insert_r(int k, int x)
{
    a[++idx] = x;
    r[idx] = r[k]; l[r[k]] = idx;
    l[idx] = k; r[k] = idx;
}

int main()
{
    int m; cin >> m;
    l[0] = r[0] = 1;
    while(m--)
    {
        string c; cin >> c;
        if(c == "L")
        {
            int x; cin >> x;
            insert_l(r[0], x);
        }
        else if(c == "R")
        {
            int x; cin >> x;
            insert_r(l[1], x);
        }
        else if(c == "D")
        {
            int k; cin >> k;
            erase(k + 1);
        }
        else if(c == "IL")
        {
            int k, x; cin >> k >> x;
            insert_l(k + 1, x);
        }
        else if(c == "IR")
        {
            int k, x; cin >> k >> x;
            insert_r(k + 1, x);
        }
    }
    int cur = r[0];
    while(cur != 1)
    {
        cout << a[cur] << ' ';
        cur = r[cur];
    }
    return 0;
}